package com.chinawlx.wlxteacher.ui.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chinawlx.wlxteacher.R;
import com.chinawlx.wlxteacher.wlx_student;

import java.util.List;

/**
 * Created by wlx on 16/10/13.
 */

public class WLXUnReadAdapter extends RecyclerView.Adapter<WLXUnReadAdapter.UnReadHolder> {
    private Context mContext;
    private List<wlx_student> wlxStudents;



    public WLXUnReadAdapter(Context mContext,List<wlx_student> wlxStudents){
        this.mContext=mContext;
        this.wlxStudents=wlxStudents;
    }
    @Override
    public WLXUnReadAdapter.UnReadHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        UnReadHolder holder = new UnReadHolder(View.inflate(mContext, R.layout
                .item_unread, null));
        return holder;
    }

    @Override
    public void onBindViewHolder(WLXUnReadAdapter.UnReadHolder holder, int position) {
        String url = wlxStudents.get(position).getAvatar_url();
        Glide.with(mContext).load(url).into(holder.headImg);
        holder.name.setText(wlxStudents.get(position).getRealname());
    }

    @Override
    public int getItemCount() {
        return wlxStudents==null?0:wlxStudents.size();
    }

    class UnReadHolder extends RecyclerView.ViewHolder{
        ImageView headImg;
        TextView name;

        public UnReadHolder(View itemView) {
            super(itemView);
            headImg =  (ImageView) itemView.findViewById(R.id.iv_icon_unread);
            name =  (TextView) itemView.findViewById(R.id.tv_name_unread);
        }
    }
}
